<template>
	<view class="container">
		<navBar title="计划详情" @goBack="uni.navigateBack()"></navBar>
		
		<view class="plan-details">
			<view class="label-content">
				<view class="title">项目名称</view>
				<view class="value-content">{{ constructionPlanDetails.pmName }}</view>
			</view>
			<view class="label-content">
				<view class="title">区间/站点</view>
				<view class="value-content no-overflow">{{ constructionPlanDetails.planConstructionSiteSectionListStr }}</view>
			</view>
			<view class="label-content">
				<view class="title">监控室值班人</view>
				<view class="value-content">{{ constructionPlanDetails.watchmanUserName }}</view>
			</view>
			<view class="label-content">
				<view class="title">现场带班负责人</view>
				<view class="value-content no-overflow">{{ constructionPlanDetails.onSiteShiftLeaderName }}</view>
			</view>
			<view class="label-content">
				<view class="title">劳务人员</view>
				<view class="value-content">{{ constructionPlanDetails.labour || 0 }}人</view>
			</view>
			<view class="label-content">
				<view class="title">特殊工种作业人员</view>
				<view class="value-content no-overflow">{{ constructionPlanDetails.personnelCallStr || '无' }}</view>
			</view>
			<view class="label-content">
				<view class="title">施工开始时间</view>
				<view class="value-content">{{ constructionPlanDetails.constructionStartTime }}</view>
			</view>
			<view class="label-content">
				<view class="title">施工结束时间</view>
				<view class="value-content">{{ constructionPlanDetails.constructionEndTime }}</view>
			</view>
			<view class="label-content">
				<view class="title">提交时间</view>
				<view class="value-content">{{ constructionPlanDetails.recordCreateDate }}</view>
			</view>
			<view class="label-content">
				<view class="title">提交人</view>
				<view class="value-content">{{ constructionPlanDetails.creatorUserName }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getConstructionPlanDetails } from "@/api/conditionalAcceptance/constructionPlan.js"
	import { handleFormatDate } from "@/utils/date.js"
	export default {
		data() {
			return {
				constructionPlanDetails: {}
			}
		},
		onLoad(options) {
			this.getConstructionPlanDetails(Number(options.id))
		},
		methods: {
			getConstructionPlanDetails(id) {
				getConstructionPlanDetails({ id }).then(res => {
					if (res && res.result) {
						const data = res.result
						this.constructionPlanDetails = {
							...data,
							planConstructionSiteSectionListStr: data.planConstructionSiteSectionList.map(item => item.lineSiteSectionName).join("、"),
							onSiteShiftLeaderName:data.personnelCallList.filter(it => it.relationType === 'xcdb').map(item => item.personName).join("、"),
							personnelCallStr: data.personnelCallList.filter(it => it.relationType === 'tsgz').map(item => item.personName).join("、"),
							constructionStartTime: data.constructionStartTime ? handleFormatDate(new Date(data.constructionStartTime), 3) : '',
							constructionEndTime: data.constructionEndTime ? handleFormatDate(new Date(data.constructionEndTime), 3) : '',
							recordCreateDate: data.recordCreateDate ? handleFormatDate(new Date(data.recordCreateDate), 3) : '',
						}
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		box-sizing: border-box;
		height: 100vh;
		overflow: hidden;
		/* #ifdef MP-WEIXIN */
		padding-top: 200rpx;
		/* #endif */
	}
	.plan-details {
		border-top: 20px solid #f5f7fa;
		background: #fff;
		height: 100%;
		.label-content {
			padding: 0 16px;
			line-height: 50px;
			font-size: 16px;
			border-top: 1px solid #f4f5f8;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-weight: bold;
			&:nth-child(1) {
				border-top: none;
			}
			.title {
				color: #445469;
				flex-shrink: 0;
				margin-right: 30px;
			}
			.value-content {
				color: #22204e;
				text-align: right;
				text-overflow: ellipsis;
				white-space: nowrap;
				overflow: hidden;
			}
			.no-overflow {
				text-overflow: initial;
				white-space: initial;
				overflow: initial;
				line-height: initial;
			}
		}
	}
</style>
